layui.use(['element', 'layer', 'form', 'layedit', 'jquery'], function() {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var layedit = layui.layedit;
    var element = layui.element;
    $(document).ready(function() {
        if (window.location.search.indexOf("?") < 0) { //判断是否是第一次加载
            var index  = layer.load(1);
            console.log(222);
            setTimeout(function() {
                $('#middleConter').attr('src', '../dataStorage/dataShowMain.html?ranparam=random()');
                layer.close(index);
            }, 500);
        } else {}
    });
  
});


function toJsonTree(regionData){
    var result=[];
    if(regionData&&regionData.length>0){
        var rowMap={};
        for(var i=0;i<regionData.length;i++){
            var row =regionData[i];
            var id = row.id;
            rowMap[id]={
                id:row.id,
                text:row.name,
                tags:row,
                children:[]
            };
        };
        for(var i=0;i<regionData.length;i++){
            var row =regionData[i];
            var id = row.id;
            var pid = row.parent_id;
            var prow=rowMap[pid];
            if(!pid||!prow){
                result.push(rowMap[id]);
            }
            if(prow){
                prow.children =prow.children||[];
                prow.children.push(rowMap[id]);
            }
        };
    }
    return result;
};
